import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;

import java.io.BufferedWriter;
import java.io.FileWriter;

/**
 * hbase 测试数据生成
 * 导入命令：
 * bin/psql.py -t PINFO h1:2181 /root/info.csv
 */
public class GenCsv {
    public static void main(String[] args) throws Exception {
        BufferedWriter bw = new BufferedWriter(new FileWriter("d:/info.csv"));
        //id,name,sex,age,city,job,phone
        String name = null;
        String age = null;
        String sex = null;
        String city = null;
        String job = null;
        String phone = null;

        for(int i = 0; i<100000000;i++){

            name = RandomStringUtils.randomAlphabetic(4,8);
            age = RandomStringUtils.randomNumeric(1,3);
            sex = (RandomUtils.nextBoolean()?0:1)+"";
            city = RandomStringUtils.randomAlphabetic(4,8);
            job = RandomStringUtils.randomAlphabetic(3,6);
            phone = RandomStringUtils.randomNumeric(12);

            bw.write(i+","+name+","+age+","+sex+","+city+","+job+","+phone);
            bw.newLine();
        }
        bw.flush();
        bw.close();

    }
}
